﻿<!DOCTYPE html>

<html>
<head>
    <title></title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />

    <link rel="stylesheet" type="text/css" href="../miniui/themes/default/miniui.css" />
    <link rel="stylesheet" type="text/css" href="../miniui/themes/icons.css" />
    <script type="text/javascript" src="//fortunearterial.mysoft.com.cn:8001/jquery-2.0.3.js?ver=2.0.3"></script>
    <script src="../miniui/miniui.js" type="text/javascript"></script>

    <style type="text/css">
        html, body {
            font-size: 12px;
            padding: 0;
            margin: 0;
            border: 0;
            height: 100%;
            overflow: hidden;
        }

        .mini-textbox {
            width: 100%;
        }
    </style>
</head>
<body>

    <form id="form" method="post">
        <input name="id" class="mini-hidden" />
        <input name="User_ID" class="mini-hidden" />
        <div style="padding: 0 11px 5px;">
            <table style="width: 100%;">
                <colgroup>
                    <col  style="width: 70px;" />
                    <col />
                </colgroup>
                <tr>
                    <td>名称：</td>
                    <td>
                        <input name="Name" class="mini-textbox" required="true" emptytext="Name" />
                    </td>
                </tr>
                <tr>
                    <td>编码：</td>
                    <td>
                        <input name="Code" class="mini-textbox" required="true" />
                    </td>
                </tr>
                <tr>
                    <td>父级编码：</td>
                    <td>
                        <input name="ParentCode" class="mini-textbox" />
                    </td>
                </tr>
            </table>
        </div>
        <div class="mini-toolbar" style="text-align:center;padding-top:8px;padding-bottom:8px;" 
            borderStyle="border-left:0;border-bottom:0;border-right:0;">
            <a class="mini-button" onclick="onOk" style="width: 60px; margin-right: 20px;">确定</a>
            <a class="mini-button" onclick="onCancel" style="width: 60px;">取消</a>
        </div>
    </form>

    <script type="text/javascript">
        mini.parse();

        var form = new mini.Form("form");

        function SaveData() {
            var o = form.getData();

            form.validate();
            if (form.isValid() == false) return;

            var json = mini.encode(o);
            $.ajax({
                url: "/Model/UserKnowledgeDetailsType/",
                type: o.id ? 'PUT': 'POST',
                data: $.parseJSON(json)
            }).then(function (ar) {
                if (ar.Success) {
                    CloseWindow("save");
                } else {
                    alert(ar.Data);
                    CloseWindow();
                };
            });
        }

        ////////////////////
        //标准方法接口定义
        function SetData(data) {
            if (data.action == "edit") {
                //跨页面传递的数据对象，克隆后才可以安全使用
                data = mini.clone(data);

                $.ajax({
                    url: "/Model/UserKnowledgeDetailsType/CURD/" + data.id,
                    success: function (json) {
                        form.setData(json);
                    }
                });
            } else {
                form.setData({ User_ID: data.User_ID });
            };
            form.setChanged(false);
        }

        function GetData() {
            var o = form.getData();
            return o;
        }
        function CloseWindow(action) {
            if (action == "close" && form.isChanged()) {
                if (confirm("数据被修改了，是否先保存？")) {
                    return false;
                }
            }
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();
        }
        function onOk(e) {
            SaveData();
        }
        function onCancel(e) {
            CloseWindow("cancel");
        }
    </script>
</body>
